package com.huawei.myapplication;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;

/**
 * @ClassName: BannerAd1$
 * @Description: 作用
 * @Author: letquit
 * @CreateDate: 6/1/2022$
 * @Version: 1.0
 */
public class BannerAd1 extends BannerAdapter<BannerAd1.bannerInfo, BannerAd1.Vh> {


    public BannerAd1(List<bannerInfo> datas) {
        super(datas);
    }

    @Override
    public Vh onCreateHolder(ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.ad_banner, viewGroup, false);
        return new BannerAd1.Vh(view);
    }

    @Override
    public void onBindView(Vh vh, bannerInfo bannerInfo, int i, int i1) {
        Glide.with(vh.ig.getContext()).load(bannerInfo.getImg()).into(vh.ig);
        vh.tv.setText(bannerInfo.getTitle());
    }

    static class Vh extends RecyclerView.ViewHolder{
        ImageView ig;
        TextView tv;
        public Vh(@NonNull View itemView) {
            super(itemView);
            ig = itemView.findViewById(R.id.ig);
            tv = itemView.findViewById(R.id.tv);
        }
    }

    static class bannerInfo {
        private String title;
        private int img;

        public bannerInfo(String title, int img) {
            this.title = title;
            this.img = img;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public int getImg() {
            return img;
        }

        public void setImg(int img) {
            this.img = img;
        }
    }
}
